package bpm.dao.impl.proposal;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import bpm.domain.proposal.Proposal;
import bpm.domain.proposal.ProposalConfiguration;
import bpm.domain.proposal.ReplyGroup;
import bpm.domain.user.OrgGroup;
import bpm.domain.user.OrgUser;

public class ProposalMapper implements RowMapper {

	public Object mapRow(ResultSet rs, int i) throws SQLException {
		 
		Proposal p=new Proposal();
		p.setId(rs.getString("ID"));
		p.setCode(rs.getString("PROPOSAL_CODE"));
		p.setTitle(rs.getString("TITLE"));
		p.setSourceType(rs.getString("SOURCE_TYPE"));
		p.setExecuteType(rs.getString("EXECUTE_TYPE"));
		p.setProposer(rs.getString("PROPOSER"));
		p.setYear(rs.getString("PROPOSAL_YEAR"));
		p.setExFocusInString(rs.getString("EX_FOCUS"));
		p.setInFocusInString(rs.getString("IN_FOCUS"));
		p.setSupervisedCount(rs.getInt("SUPERVISED_COUNT")+"");
		p.setDeadLine(rs.getDate("DEADLINE"));
		p.setExecuteResult(rs.getString("EXECUTE_RESULT"));
		
		ReplyGroup rg=new ReplyGroup();
		rg.setRgID(rs.getString("RG_ID"));
		p.setReplyGroup(rg);
		p.setPublishDocId(rs.getString("PUBLISH_DOC_ID"));
		p.setPublishDocCode(rs.getString("PUBLISH_DOC_CODE"));
		p.setExecuteDeptId(rs.getString("EXECUTE_DEPTID"));
		p.setExecuteDeptName(rs.getString("EXECUTE_DEPT"));
		p.setExecuteDevisionId(rs.getString("EXECUTE_DEVISIONID"));
		p.setExecuteDevisionName(rs.getString("EXECUTE_DEVISION"));
		
		
		p.setExecutePersonId(rs.getString("EXECUTE_PERSONID"));
		p.setExecutePersonName(rs.getString("EXECUTE_PERSON"));
		
		
		
		ProposalConfiguration pc=new ProposalConfiguration();
		pc.setId(rs.getString("ID"));
		pc.setCompleted(rs.getString("COMPLETED").equals("1")?true:false);
		p.setProposalConfiguration(pc);
		return p;
		
	}
}
